package com.chuanyang.driverh.mainhome.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.chuanyang.driverh.R;
import com.chuanyang.driverh.base.BaseListAdapter;
import com.chuanyang.driverh.response2.join.ResultAddList;
import com.chuanyang.driverh.utils.BitmapUtil;
import com.chuanyang.driverh.utils.widget.GlideCircleTransform;


public class RecommendAdapter extends BaseListAdapter<ResultAddList.DataBeanX.DataBean> {
    private Context mContext;

    public RecommendAdapter(Context context) {
        super(context);//此处不传入集合，则默认集合长度为0，在setdataresult（）方法中，添加数据并刷新
        this.mContext = context;
    }

    @Override
    public View getZkView(final int position, View convertView, final ViewGroup parent) {
        ViewHolder viewHolder = null;
        if (convertView == null) {
            convertView = getInflater().inflate(R.layout.add_item, parent, false);
            viewHolder = new ViewHolder();
            viewHolder.iv_photo = (ImageView) convertView.findViewById(R.id.iv_photo);
            viewHolder.tv_name = (TextView) convertView.findViewById(R.id.tv_name);
            viewHolder.tv_jiameng_num = (TextView) convertView.findViewById(R.id.tv_jiameng_num);
            viewHolder.tv_order_num = (TextView) convertView.findViewById(R.id.tv_order_num);
            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        final ResultAddList.DataBeanX.DataBean data = getItem(position);
        //BitmapUtil.showImgForNetPath(data.getImage(),viewHolder.iv_photo);
        Glide.with(mContext).load(data.getImage()).crossFade().placeholder(R.mipmap.group_chat).
                error(R.mipmap.group_chat).transform(new GlideCircleTransform(mContext)).into(viewHolder.iv_photo);
        viewHolder.tv_name.setText(data.getFleetName());
        viewHolder.tv_jiameng_num.setText(data.getJoinedNum()+"人已加盟");
        viewHolder.tv_order_num.setText(data.getWaybillNum()+"单");

        return convertView;
    }

    class ViewHolder {
        ImageView iv_photo;
        TextView tv_name;
        TextView tv_jiameng_num;
        TextView tv_order_num;
    }

}
